using System;
using System.Runtime.InteropServices;
using System.Drawing.Printing;
using System.Security.Permissions;

namespace qPrintComponent
{
    public class qSafeDriverInfo : qSafeInfo
    {
        
        protected qSafeDriverInfo(SafeHandle PrinterHandle, int level) 
            : base(PrinterHandle, level)
        {}
        
        internal qSafeDriverInfo(IntPtr MemoryHandle, int level)
            : base(MemoryHandle, level)
        {}
        
        [PrintingPermission(SecurityAction.Demand, Level = PrintingPermissionLevel.DefaultPrinting)]
        protected override void RefreshInfo()
        {
            if (!qStatic.GetPrinterDriver(PrinterHandle, IntPtr.Zero, Level, handle, Size, out BytesNeeded) && (BytesNeeded > 0))
            {
                AllocMem();
                if (!qStatic.GetPrinterDriver(PrinterHandle, IntPtr.Zero, Level, handle, Size, out BytesNeeded) && (BytesNeeded > 0))
                    throw new System.ComponentModel.Win32Exception("DriverInfo" + Level.ToString(System.Globalization.CultureInfo.InvariantCulture) + " Error");
            }
        }
        protected override bool Update()
        {
            //setprinterdriver...
            throw new NotImplementedException();
        }
    }
}
